<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>发布生产大数据</title>
		<link href="__CSS__/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__CSS__/iconfont.css" />
		<link rel="stylesheet" href="__CSS__/style.css" />
		<link rel="stylesheet" href="__CSS__/mall.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-icon mui-icon-left-nav mui-pull-left" onclick='window.location.href="{:url('member/index')}"'></a>
			<h1 class="mui-title">发布生产大数据</h1>
		</header>
		<div class="mui-content ">
			<div class="gerenzl_nr">
				<form id="myForm" class="mui-input-group gerenzl_group">
					<div class="mui-input-row ">
						<label><em>*</em>产品名称</label>
						<input type="text" name="name" class="mui-input-group" placeholder="请填写产品名称">
					</div>
					<div class="mui-input-row ">
						<label style="width: 50%;">建档立卡扶贫户</label>
						<select style="width: 40%;" class="mui-btn mui-btn-block" name="jiandang" >
							<option value="0">否</option>
							<option value="1">是</option>
						</select>
					</div>
					<div class="mui-input-row ">
						<label><em>*</em>产品图</label>
						<div class="actions" style="float: right;">
							<div class="file-btn" style="border: 1px solid #CCCCCC;">
								<input type="hidden" id="thumb" name="thumb">
								<input onchange="UpladFile('product', 500)" type="file" accept="image/*" id="file" name="file"  multiple>
								<span><img class='img_list' src="__IMG__/logo1.png" id='thumb_img' style="width: 100%;height: 100%;border-radius: 100%" ></span>
							</div>
						</div>
					</div>
					<div class="mui-input-row">
						<label><em>*</em>一级分类</label>
						<select class="mui-btn mui-btn-block" name="cate_id1" id="cate1">
							{foreach name='cate' item='vo'}
							<option value="{$vo.id}">{$vo.name}</option>
							{/foreach}
						</select>
					</div>
					<div class="mui-input-row">
						<label><em>*</em>二级分类</label>
						<select class="mui-btn mui-btn-block" name="cate_id2" id="cate2">
							{foreach name='cate2' item='vo'}
							<option value="{$vo.id}">{$vo.name}</option>
							{/foreach}
						</select>
					</div>
					<div class="mui-input-row">
						<label><em>*</em>产品品类</label>
						<select class="mui-btn mui-btn-block" name="cate_item" id="cate3">
							{foreach name='cate3' item='vo'}
							<option value="{$vo.id}">{$vo.name}</option>
							{/foreach}
						</select>
					</div>
					<div class="mui-input-row">
						<label><em>*</em>产品价格</label>
						<input type="text" name="price" class="mui-input-group" placeholder="请填写价格描述,面议请填写0">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>价格单位</label>
						<select class="mui-btn mui-btn-block" name="unit" id="unit">
							<option value="斤">元/斤</option>
							<option value="吨">元/吨</option>
							<option value="个">元/个</option>
							<option value="支">元/支</option>
							<option value="包">元/包</option>
							<option value="箱">元/箱</option>
							<option value="升">元/升</option>
							<option value="袋">元/袋</option>
							<option value="棵">元/棵</option>
							<option value="头">元/头</option>
							<option value="盒">元/盒</option>
							<option value="厅">元/厅</option>
							<option value="毫升">元/毫升</option>
							<option value="只">元/只</option>
							<option value="台">元/台</option>
							<option value="千克">元/千克</option>
							<option value="匹">元/匹</option>
							<option value="枚">元/枚</option>
							<option value="件">元/件</option>
							<option value="瓶">元/瓶</option>
							<option value="辆">元/辆</option>
							<option value="平方">元/平方</option>
							<option value="张">元/张</option>
						</select>
					</div>
					<div class="hy_line"></div>
					<div class="mui-input-row">
						<label><em>*</em>生产时间</label>
						<input style="height: 40px;" name="produce_time" value="" readonly data-options='{"type":"date","beginYear":1901,"endYear":{:date("Y")}}' class="btns mui-input-group" placeholder="选择生产时间">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>预计销售时间</label>
					</div>
					<div class="mui-input-row">
						<input style="width: 45%;text-align: center;height: 40px;" readonly name="sell_start" value="" data-options='{"type":"date","beginYear":{:date("Y")},"endYear":{:date("Y")+3}}' class="btns mui-input-group" placeholder="选择开始时间"> 到
						<input style="width: 45%;text-align: center;height: 40px;" readonly name="sell_end" value="" data-options='{"type":"date","beginYear":{:date("Y")},"endYear":{:date("Y")+3}}' class="btns mui-input-group" placeholder="选择结束时间">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>每日供应量</label>
						<input type="text" name="day_total" class="mui-input-group" placeholder="请填写每天可供应量">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>预计产量</label>
						<input type="text" name="yj_total" class="mui-input-group" placeholder="请填写预计产量">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>总产量</label>
						<input type="text" name="total" class="mui-input-group" placeholder="请填写本年度本产品生产总量">
					</div>
					<div class="mui-input-row ">
						<label style="width: 50%;">已有销售途径量</label>
						<input style="width: 40%;" type="text" name="marketing" class="mui-input-group" placeholder="请填写已有销售途径量">
					</div>
					<div class="mui-input-row ">
						<label style="width: 40%;">库存量</label>
						<input style="width: 50%;" type="text" name="stocking" class="mui-input-group" placeholder="请填写现有的库存量">
					</div>
					<div class="hy_line"></div>
					<div class="mui-input-row">
						<label><em>*</em>地区</label>
						<input type="text" readonly="" placeholder="请选择地区" id="myAddrs" data-key="" value="">
						<input type="hidden" id="area" name="area" value="" />
					</div>
					<div class="mui-input-row">
						<label>详细地址</label>
						<input type="text" name="address" class="mui-input-group" placeholder="请填写详细地址">
					</div>
					<div class="mui-input-row">
						<label>详细图片</label>
						<div class="ordpj_imgbox">
							<div id="img_list" class="img_list">
							</div>
						</div>
						<div class="mui-input-row">
							<button class="file-btn">
				                <span><i class="mui-icon mui-icon-camera fa"></i></span>
				                <input onchange="UpladFiles('product', 900)" type="file" accept="image/*" id="files" name="files"  multiple>
				            </button>
						</div>
						<div class="mui-input-row">
							<label>备注</label>
							<textarea name="content" style="width:100%;height:150px;border: 1px solid #CCCCCC;"></textarea>
						</div>
						<button type="submit" class="fjysq_sbtn">免费发布</button>
						<div class="mui-input-row" style="height:80px;line-height: 80px; text-align: center;">
						让政府和商家知道您的产品
						</div>
					</div>
				</form>
			</div>
		</div>
	</body>

</html>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/jquery.validate.min.js"></script>
<script src="__JS__/mui.min.js"></script>
<script src="__LIB__/layer.js"></script>
<script src="__JS__/image.zip.js"></script>
<script src="__JS__/index.js"></script>
<!-- 时间选择器-->
<link rel="stylesheet" type="text/css" href="__JS__/mui.picker.min.css" />
<script src="__JS__/mui.picker.min.js"></script>
<!-- end 时间选择器-->
<link href="__JS__/scs.min.css" rel="stylesheet">
<script src="__JS__/jquery.scs.min.js"></script>
<script src="__JS__/district.js"></script>

<script>
	(function($) {
		$.init();
		var btns = $('.btns');
		btns.each(function(i, btn) {
			btn.addEventListener('tap', function() {
				var _self = this;
				if(_self.picker) {
					_self.picker.show(function(rs) {
						_self.value = rs.text;
						_self.picker.dispose();
						_self.picker = null;
					});
				} else {
					var optionsJson = this.getAttribute('data-options') || '{}';
					var options = JSON.parse(optionsJson);
					var id = this.getAttribute('id');
					_self.picker = new $.DtPicker(options);
					_self.picker.show(function(rs) {
						_self.value = rs.text;
						_self.picker.dispose();
						_self.picker = null;
					});
				}
			}, false);
		});
	})(mui);
	$(function() {
		// 二级联动
		$("#cate1").change(function() {
			var pid = $(this).val();
			$.ajax({
				type: "post",
				url: "{:url('member/product_cates')}",
				data: {
					pid: pid
				},
				success: function(json) {
					if(json.code == 1) {
						str = '';
						for(var i = 0; i < json.data.length; i++) {
							str += '<option value="' + json.data[i].id + '">' + json.data[i].name + '</option>';
						}
						$("#cate2").html(str);
						$("#cate2").change();
					} else {
						layer.msg(json.msg);
					}
				}
			});
		});

		// 三级联动
		$("#cate2").change(function() {
			var pid = $(this).val();
			$.ajax({
				type: "post",
				url: "{:url('member/product_items')}",
				data: {
					pid: pid
				},
				success: function(json) {
					$("#cate3").html("");
					if(json.code == 1) {
						str = '';
						for(var i = 0; i < json.data.length; i++) {
							str += '<option value="' + json.data[i].id + '">' + json.data[i].name + '</option>';
						}
						$("#cate3").html(str);
					} else {
						layer.msg(json.msg);
					}
				}
			});
		});

		$("#myForm").validate({
			focusInvalid: true,
			onkeyup: false,
			ignore: "",
			onfocusout: false,
			showErrors: function(errorMap, errorList) {
				var msg = "";
				if(errorList != null && errorList != "") {
					msg = errorList[0]['message'];
					layer.msg(msg);
				}
			},
			submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
				app.ajax(window.location.href, true);
			},
			rules: {
				name: {
					required: true
				},
				thumb: {
					required: true
				},
				area: {
					required: true
				},
				price: {
					required: true
				},
				unit: {
					required: true
				},
				produce_time: {
					required: true
				},
				sell_start: {
					required: true
				},
				sell_end: {
					required: true
				},
				day_total: {
					required: true
				},
				yj_total: {
					required: true
				},
				total: {
					required: true
				}
			},
			messages: {
				name: {
					required: "请填写产品名称"
				},
				thumb: {
					required: "请上传产品图片"
				},
				area: {
					required: "请选择地区"
				},
				price: {
					required: "请填写产品价格"
				},
				unit: {
					required: "请选择单位"
				},
				produce_time: {
					required: "请选择生产时间"
				},
				sell_start: {
					required: "请选择预售开始时间"
				},
				sell_end: {
					required: "请选择预售结束时间"
				},
				day_total: {
					required: "请填写每天可供应量"
				},
				yj_total: {
					required: "请填写预计产量"
				},
				total: {
					required: "请填写总产量"
				}
			}
		});
	});
</script>